package com.waimai1.waimai.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.waimai1.waimai.common.BaseContext;
import com.waimai1.waimai.dao.QuanyiPersonDao;
import com.waimai1.waimai.dto.CouponPersonWhiteDto;
import com.waimai1.waimai.entity.QuanyiPerson;
import com.waimai1.waimai.service.QuanyiPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * (QuanyiPerson)表服务实现类
 *
 * @author makejava
 * @since 2024-03-05 19:51:43
 */
@Service("quanyiPersonService")
public class QuanyiPersonServiceImpl extends ServiceImpl<QuanyiPersonDao, QuanyiPerson> implements QuanyiPersonService {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public  void saveExcel(List<CouponPersonWhiteDto> whiteList) {
        Set phones=new HashSet();
        for(CouponPersonWhiteDto white:whiteList){
            phones.add(white.getPhone());
        }
        redisTemplate.opsForSet().add(BaseContext.getAcid()+":quanyiWhite"+ BaseContext.getSort(),phones.toArray());
    }
    @Override
    public void clearExcelRedis(){
        redisTemplate.delete(BaseContext.getAcid()+":quanyiWhite"+BaseContext.getSort());
    }
    @Override
    public  long saveWhite(String[] phones) {
        return redisTemplate.opsForSet().add(BaseContext.getAcid()+":quanyiWhite"+BaseContext.getSort(), phones);
    }
    @Override
    public void clearQuanyiWhiteRedis(String sort){
        redisTemplate.delete(BaseContext.getAcid()+":quanyiWhite"+sort);
    }
}

